package com.itheima.reggie.common;

/**
 * 维护ThreadLocal对象
 */
public class BaseContext {

    //定义ThreadLocal
    private static final ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    //设置数据到当前线程
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    //获取当前线程的数据
    public static Long getCurrentId(){
        return threadLocal.get();
    }

    //释放当前线程的数据
    public static void remove(){
         threadLocal.remove();
    }

}
